<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<script src="../vue.js"></script>
<script src="./js/lodash.min.js"></script>
<style>
  .list-item {
    width: 25px;
    height: 25px;
    display: inline-block;
    margin-right: 10px;
    background-color: pink;
    border-radius: 50%;
    text-align: center;
    color: #fff;
  }

  .list-enter-active {
    transition: all 1s;
  }

  .list-leave-active {
    transition: all 1s;
    /* 绝对定位 */
    position: absolute;
  }

  .list-enter,
  .list-leave-to {
    opacity: 0;
    transform: translateY(45deg);
  }

  .list-move {
    transition: all 1s;
  }
</style>

<body>
  <div id="app">
    <button @click="shuffle">洗牌</button>
    <transition-group name="list" tap="p">
      <span v-for="(item,index) in items" :key="item" class="list-item">{{item}}</span>
    </transition-group>
  </div>

  <script>
    var vm = new Vue({
      el: "#app",
      data: {
        items: [1, 2, 3, 4, 5, 6, 7, 9, 8]
      },
      methods: {
        shuffle() {
          // shuffle()函数把数组中的元素按随机顺序重新排列
          this.items = _.shuffle(this.items);
        }
      }
    })
  </script>
</body>

</html>